package core;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * describe:
 *
 * @author helloworldyu
 * @data 2018/3/26
 */
public class NonOwnerInvocationHandler implements InvocationHandler{
	IPerson person;

	public NonOwnerInvocationHandler(IPerson person) {
		this.person = person;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		//==================设置别人的信息不行=============
		if( method.getName().startsWith("setHotOrNotRating")|| method.getName().startsWith("get") ){
			return method.invoke(person,args);
		}else if (method.getName().startsWith("set") ){
			throw new IllegalAccessException("没有权限设置别人的信息");
		}else {
			return null;
		}
	}
}